;=================================================
; number, characters and strings sample
;

(load "common.lsp")

;=================================================
; standard way to compute factorial using recursive
; descending method
(defun factorial-r (n)
 (if (> n 2)
  (* (factorial-r (1- n)) n)
  1
  ) ; if
 ) ; factorial-r

;=================================================
; way to compute fibonnaci using loop
(defun fib-l (n)
 (if (< n 1)
  nil
  (let ((a1 1) (a2 1))
   (loop for i from 3 to n do
    (let ((at a2))
     (setf a2 (+ a1 a2))
     (setf a1 at)))
   a2 ; return result variable
   ) ; let
 ) ; if
 ) ; fib-l

;=================================================
; notes to characters comparison function
;   Numeric Analog	Case-Sensitive	Case-Insensitive
;-------------------------------------------------
;   =	            CHAR=	        CHAR-EQUAL
;   /=	            CHAR/=	        CHAR-NOT-EQUAL
;   <	            CHAR<	        CHAR-LESSP
;   >	            CHAR>	        CHAR-GREATERP
;   <=	            CHAR<=	        CHAR-NOT-GREATERP
;   >=	            CHAR>=	        CHAR-NOT-LESSP
; ---
;   Numeric Analog	Case-Sensitive	Case-Insensitive
;   =	            STRING=	        STRING-EQUAL
;   /=	            STRING/=	    STRING-NOT-EQUAL
;   <	            STRING<	        STRING-LESSP
;   >	            STRING>	        STRING-GREATERP
;   <=	            STRING<=	    STRING-NOT-GREATERP
;   >=	            STRING>=	    STRING-NOT-LESSP
;
;

;=================================================
; main test function
;
(defun test ()
 ; 1
 (trace-fn
  "numbers"
  (factorial-r 10)
  (fib-l 5)
  (/= 1 2 3)
  (/= 1 2 3 1.0)
  (= 1 2 3 4)
  (/ 10 5)
  (* #c(1 2) #c(3 4))

  "chars"
  (char= #\a #\a)

  "strings"
  (string= "foobarbaz" "quuxbarfoo" :start1 3 :end1 6 :start2 4 :end2 7)
  )

 ; 2
 )

;=================================================
; app entry point
;
(defun main ()

 (format t "numbers characters and strings sample~%=====~%")

 (test)

 (exit)
 )

;=================================================
; executes main
;
(main)
